package com.hezuti.info.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Property;
import org.springframework.stereotype.Component;

import com.hezuti.common.dao.BaseHibernateDaoGeneric;
import com.hezuti.info.domain.School;

/**
 * 
 * @author Administrator
 *
 */
@Component
public class SchoolDao extends  BaseHibernateDaoGeneric<School> {
	/**
	 * 按照省份找 大学
	 * @param pid
	 * @return
	 */
	public List<School> findCollagesByPid(int pid){
		Criteria criteria = this.createCriteria(Property.forName(School.FIELD_PID).eq(pid),Property.forName(School.FIELD_STYPE).eq(School.STYPE_COLLAGE));
		List<School> l = findBy(criteria);
		return l;
	}
	
	/**
	 * 按照 区域查找中专<br/>
	 * @param did
	 * @return
	 */
	public List<School> findZhongzhuanByDistrict(int did){
		Criteria criteria = this.createCriteria(Property.forName(School.FIELD_DID).eq(did),Property.forName(School.FIELD_STYPE).eq(School.STYPE_ZhongZhuan));
		return findBy(criteria);
	}
	/**
	 * 按照地区找高中
	 * @param did
	 * @return
	 */
	public List<School> findGaoZhongByDistrict(int did){
		Criteria criteria = this.createCriteria(Property.forName(School.FIELD_DID).eq(did),Property.forName(School.FIELD_STYPE).eq(School.STYPE_MIDDLE_SCHOOL));
		return findBy(criteria);
	}
	/**
	 * 按照地区找初中
	 * @param did
	 * @return
	 */
	public List<School> findChuZhongByDistrict(int did){
		Criteria criteria = this.createCriteria(Property.forName(School.FIELD_DID).eq(did),Property.forName(School.FIELD_STYPE).eq(School.STYPE_JUNIOR_SCHOOL));
		return findBy(criteria);
	}
	
	
	/**
	 * 按照学校类别查询所有的学校
	 * 
	 * @param stype
	 * @return
	 */
	public List<School> findByStype(int stype){
		Criteria criteria = this.createCriteria(Property.forName(School.FIELD_STYPE).eq(stype));
		return findBy(criteria);
	}

	/**
	 * 按照国家id查找所有学校
	 * @param cid
	 * @return
	 */
	public List<School> findByCountry(int cid){
		Criteria criteria = this.createCriteria(Property.forName(School.FIELD_CID).eq(cid));
		return findBy(criteria);
	}
}
